console.log('hello')

let age: number = 20
console.log(age)

let numbers: number[] = [1,2,3,4]

for (const key in numbers) {
    console.log(key) 
    
}

let b: boolean[] = [true, true, false]
b.forEach(element => {
    console.log(element)
});

let arr: (number | string)[]=['a',4,'y',1,2,3]
arr.flatMap(ele=>{
    console.log(ele)
})

arr.forEach(ele => {
console.log(ele)
})

function add(num1:number, num2:number):number {
    return num1 + num2
}
console.log("plus=="+ add(3, 9))

//等价写法
const add2 = (num1: number, num2: number): number => {
    return num1 + num2
}
console.log("plus2=="+ add2(6, 8))



function greet(name: string): void {
    console.log("hello " + name)
}
greet('wade')

//等价写法
const greet2 = (name: string): void =>{
    console.log("hello " + name)
}
greet2('james');


//字面量类型
function changeDirection(direction: 'up' | 'down' | 'left' | 'right'): void{

}

changeDirection('left')

//枚举类型
enum Direction{up, down, left, right}

function printDirection(direction: Direction): void {
    console.log('direction==' + direction)
}

printDirection(Direction.left)